package com.shunli.cterminal.service.impl;

import com.examples.core.exception.ServiceException;
import com.examples.core.mybatis.service.AbstractService;
import com.shunli.cterminal.entity.SystemBizTemplate;
import com.shunli.cterminal.mapper.SystemBizTemplateMapper;
import com.shunli.cterminal.model.res.GoodsTemplateVO;
import com.shunli.cterminal.model.code.CterminalResultCode;
import com.shunli.cterminal.service.TemplateService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @ClassName: TemplateServiceImpl
 * @Description: TODO
 * @Author: DAIYALU
 * @Date: 2025/4/24
 * @Version: 1.0
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class TemplateServiceImpl extends AbstractService<SystemBizTemplateMapper, SystemBizTemplate> implements TemplateService {

    @Override
    public GoodsTemplateVO queryGoodsTemplate(Long templateId) {
        if(null == templateId){
            throw new ServiceException(CterminalResultCode.TEMPLATE_NOT_EXIST);
        }
        GoodsTemplateVO bo = this.baseMapper.queryGoodsTemplate(templateId);
        if(null == bo){
            throw new ServiceException(CterminalResultCode.TEMPLATE_NOT_EXIST);
        }
        bo.setDetails(this.baseMapper.queryTemplateDetailByTemplateId(templateId));
        return bo;
    }

    @Override
    public BigDecimal queryTemplateRedBag(Long templateId) {
        return this.baseMapper.queryTemplateRedBag(templateId);
    }
}
